package com.iflytek.exam.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.iflytek.common.annotation.Log;
import com.iflytek.common.core.controller.BaseController;
import com.iflytek.common.core.domain.AjaxResult;
import com.iflytek.common.enums.BusinessType;
import com.iflytek.exam.domain.ExamTeacher;
import com.iflytek.exam.service.IExamTeacherService;
import com.iflytek.common.utils.poi.ExcelUtil;
import com.iflytek.common.core.page.TableDataInfo;

/**
 * teacherExamController
 * 
 * @author Dogdog
 * @date 2024-07-10
 */
@RestController
@RequestMapping("/exam/teacherExam")
public class ExamTeacherController extends BaseController
{
    @Autowired
    private IExamTeacherService examTeacherService;

    /**
     * 查询teacherExam列表
     */
    @PreAuthorize("@ss.hasPermi('exam:teacherExam:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamTeacher examTeacher)
    {
        startPage();
        List<ExamTeacher> list = examTeacherService.selectExamTeacherList(examTeacher);
        return getDataTable(list);
    }

    /**
     * 导出teacherExam列表
     */
    @PreAuthorize("@ss.hasPermi('exam:teacherExam:export')")
    @Log(title = "teacherExam", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamTeacher examTeacher)
    {
        List<ExamTeacher> list = examTeacherService.selectExamTeacherList(examTeacher);
        ExcelUtil<ExamTeacher> util = new ExcelUtil<ExamTeacher>(ExamTeacher.class);
        util.exportExcel(response, list, "teacherExam数据");
    }

    /**
     * 获取teacherExam详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:teacherExam:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(examTeacherService.selectExamTeacherById(id));
    }

    /**
     * 新增teacherExam
     */
    @PreAuthorize("@ss.hasPermi('exam:teacherExam:add')")
    @Log(title = "teacherExam", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamTeacher examTeacher)
    {
        return toAjax(examTeacherService.insertExamTeacher(examTeacher));
    }

    /**
     * 修改teacherExam
     */
    @PreAuthorize("@ss.hasPermi('exam:teacherExam:edit')")
    @Log(title = "teacherExam", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamTeacher examTeacher)
    {
        return toAjax(examTeacherService.updateExamTeacher(examTeacher));
    }

    /**
     * 删除teacherExam
     */
    @PreAuthorize("@ss.hasPermi('exam:teacherExam:remove')")
    @Log(title = "teacherExam", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(examTeacherService.deleteExamTeacherByIds(ids));
    }
}
